#pragma once

#include <QtCore/QString>
#include <QtCore/QByteArray>

#include "Texture.hpp"
#include "D3D11Declarations.hpp"




namespace Engine
{
	namespace Video
	{
		class D3D11Texture
			: public Texture
		{
		public:

			SHARED(D3D11Texture);
			typedef boost::function<void(weak_ptr)>   notify_t;

		protected:

			D3D11Texture(const notify_t& destroyedFn, const QByteArray& data, const ID3D11DevicePtr& device);
			void post_create(ptr _this);

		public:

			MAKE_SHARED3(D3D11Texture,notify_t,QByteArray,ID3D11DevicePtr);
			~D3D11Texture();



			/**
			 * Obtain a pointer to the resource view.
			 */
			const ID3D11ShaderResourceViewPtr& view() const;

		private:

			static ID3D11ResourcePtr createTexture(const QByteArray& data, const ID3D11DevicePtr& device);
			static ID3D11ShaderResourceViewPtr createResourceView(const ID3D11Texture2DPtr& texture, const ID3D11DevicePtr& device);

		private:

			weak_ptr                      m_this;
			notify_t                      m_destroyedFn;
			ID3D11ResourcePtr             m_texture;
			ID3D11ShaderResourceViewPtr   m_resourceView;
		};
		///////////////////////////////////////////////////////////////////////////////////////////
	}
	///////////////////////////////////////////////////////////////////////////////////////////////
}
///////////////////////////////////////////////////////////////////////////////////////////////////
